package com.lms.thread.demo1;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-01-17 10:28
 * @Description: ${Description}
 */
public class TaskThread extends Thread {
    int i;
    @Override
    public void run() {
        super.run();
        System.out.println("当前线程名："+Thread.currentThread().getName());
        System.out.println("线程运行时，线程是否处于活动状态：isAlive():"+Thread.currentThread().isAlive());
        System.out.println(Thread.currentThread().isInterrupted());//当前线程是否被中断，不会清除中断标志
        System.out.println(Thread.currentThread().isInterrupted());
        System.out.println(Thread.interrupted());//当前线程是否被中断，会清除中断标志，中断标志碰到sleep会抛出异常
        System.out.println(Thread.interrupted());
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(i++);
        }
    }
}
